package neo.aoi;

import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;

import neo.aoi.VoxelExporter.ExportParameters;
import artofillusion.LayoutWindow;
import artofillusion.ModellingTool;

/**
 * Voxel modelling tool plugin class. This class serves as a plugin for Art of
 * illusion. Using this plugin will convert the selected object to its voxel
 * representation.
 * 
 * @author Carlos Martinez
 */
public class VoxelModeller implements ModellingTool {

	/**
	 * This function is called when the Voxel modelling tool is called. This
	 * function displays the parameter input window and starts the voxelization
	 * process
	 * 
	 * @param window
	 *            The current LayoutWindow.
	 */
	public void commandSelected(LayoutWindow window) {
		ExportParameters params = VoxelExporter.getExportParameters(window,
				"Voxel modelling tool", null);
		if (params.proceed()) {
			// Launch GUI progress bar
			ExportProgressBar bar = new ExportProgressBar(window);
			SwingWorker worker = new VoxelModellerTool(params, window, bar);
			SwingUtilities.invokeLater(bar);
			worker.execute();
		}
	}

	/**
	 * Returns the name of the Voxel modelling tool which will be displayed in
	 * the 'Tools' menu.
	 * 
	 * @return A String with the text to be displayed under the 'Tools' menu.
	 */
	public String getName() {
		return "Voxelizer Tool...";
	}
}
